package com.mytijian.task.zookeeper.path;

import com.mytijian.task.util.IpAddressUtil;
import org.springframework.util.StringUtils;

public class ServerPath {
    private static String leader = "/leader";
    public static String latch = leader + "/latch";
    public static String instance = leader + "/instance";
    public static String getIntanceValue(Integer serverPort) {
        return IpAddressUtil.getLocalHost() + ":" + serverPort;
    }
    public static String getIpFromInstanceValue(String instanceValue) {
        if (StringUtils.isEmpty(instanceValue)) {
            return null;
        }
        return instanceValue.split(":")[0];
    }
}
